﻿--================================================================================================
--                                 Change History
--                                 --------------
-- Date          Who     Description
-- -----------   ------  --------------------------------------------------
-- 03/Feb/2025   AndyB   New SystemSetting: WebPlusMarkbookStatsDaysGrace
-- 02/Apr/2025   AndyB   New SystemSetting: WebPlusLandingTab
-- 02/Apr/2025   AndyB   Rename SystemSetting: WebPlusShowInYearNotes to WebPlusShowInYearNotesVA
-- 02/Apr/2025   AndyB   Rename SystemSetting: WebPlusShowEffortGrades to WebPlusShowEffortGradesVA
-- 02/Apr/2025   AndyB   New SystemSetting: WebPlusShowEffortGradesEM WebPlusShowInYearNotesEM
-- 14/May/2025   AndyB   New SystemSetting: WebPlusMarkbookCompleteTickColour and WebPlusMarkbookCompleteBgdColour
--
--------------------------------------------------------------------------------------------------
--select * from SystemSettingValue
--select * from SystemSettingFlag
--------------------------------------------------------------------------------------------------


IF NOT EXISTS (SELECT 1 FROM SystemSettingValue WHERE SystemSettingName = 'WebPlusMarkbookStatsDaysGrace')
BEGIN
	INSERT INTO	
		SystemSettingValue
			(SystemSettingID, SystemSettingName, SystemSettingDescription, DataType, DefaultValue, SystemSettingValue, SystemSettingCategoryID)
	VALUES
		((SELECT MAX(SystemSettingID)+1 FROM SystemSettingValue), 'WebPlusMarkbookStatsDaysGrace', 'The time allowed (in days) for a teacher to mark the work and enter it into the markbook', 'System.String', '14', '14', 1)
END

IF NOT EXISTS (SELECT 1 FROM SystemSettingValue WHERE SystemSettingName = 'WebPlusLandingTab')
BEGIN
	INSERT INTO	
		SystemSettingValue
			(SystemSettingID, SystemSettingName, SystemSettingDescription, DataType, DefaultValue, SystemSettingValue, SystemSettingCategoryID)
	VALUES
		((SELECT MAX(SystemSettingID)+1 FROM SystemSettingValue), 'WebPlusLandingTab', 'The tab to land upon initial load (INYEAR, SKILLS, DELTA, MARKBOOK)', 'System.String', 'INYEAR', 'INYEAR', 1)
END


IF EXISTS (SELECT 1 FROM SystemSettingValue WHERE SystemSettingName = 'WebPlusShowInYearNotes')
BEGIN
	UPDATE 
		SystemSettingValue 
	SET 
		SystemSettingName        = 'WebPlusShowInYearNotesVA',
		SystemSettingDescription = 'For VA: whether to show InYear Notes by default (YES NO)'
	WHERE 
		SystemSettingName = 'WebPlusShowInYearNotes'
END
IF EXISTS (SELECT 1 FROM SystemSettingValue WHERE SystemSettingName = 'WebPlusShowEffortGrades')
BEGIN
	UPDATE 
		SystemSettingValue 
	SET 
		SystemSettingName        = 'WebPlusShowEffortGradesVA',
		SystemSettingDescription = 'For VA: whether to show Effort Grades by default (YES NO)'
	WHERE 
		SystemSettingName = 'WebPlusShowEffortGrades'
END

IF NOT EXISTS (SELECT 1 FROM SystemSettingValue WHERE SystemSettingName = 'WebPlusShowInYearNotesEM')
BEGIN
	INSERT INTO	
		SystemSettingValue
			(SystemSettingID, SystemSettingName, SystemSettingDescription, DataType, DefaultValue, SystemSettingValue, SystemSettingCategoryID)
	VALUES
		((SELECT MAX(SystemSettingID)+1 FROM SystemSettingValue), 'WebPlusShowInYearNotesEM', 'For English/Maths: whether to show InYear Notes by default (YES NO)', 'System.String', 'NO', 'NO', 1)
END
IF NOT EXISTS (SELECT 1 FROM SystemSettingValue WHERE SystemSettingName = 'WebPlusShowEffortGradesEM')
BEGIN
	INSERT INTO	
		SystemSettingValue
			(SystemSettingID, SystemSettingName, SystemSettingDescription, DataType, DefaultValue, SystemSettingValue, SystemSettingCategoryID)
	VALUES
		((SELECT MAX(SystemSettingID)+1 FROM SystemSettingValue), 'WebPlusShowEffortGradesEM', 'For English/Maths: whether to show Effort Grades by default (YES NO)', 'System.String', 'NO', 'NO', 1)
END

GO

IF NOT EXISTS (
    SELECT 1
    FROM [dbo].[SystemSettingFlag]
    WHERE [SettingName] = 'Can edit marks recorded by others' and ID = 29
      AND [Category] = 'Markbook'
)
BEGIN
    INSERT INTO [dbo].[SystemSettingFlag] (
		ID,
        [SettingName],
        [Value],
        [Category]
    )
    VALUES (
		29,
        'Can edit marks recorded by others',
        1,                
        'Markbook'      
    );
END;
GO

IF NOT EXISTS (
    SELECT 1
    FROM [dbo].[SystemSettingFlag]
    WHERE [SettingName] = 'Auto save Markbook grid' and ID = 30
      AND [Category] = 'Markbook'
)
BEGIN
    INSERT INTO [dbo].[SystemSettingFlag] (
		ID,
        [SettingName],
        [Value],
        [Category]
    )
    VALUES (
		30,
        'Auto save Markbook grid',
        1,
		'Markbook'
    );
END;
GO

IF NOT EXISTS (SELECT 1 FROM SystemSettingValue WHERE SystemSettingName = 'WebPlusMarkbookCompleteTickColour')
BEGIN
	INSERT INTO	
		SystemSettingValue
			(SystemSettingID, SystemSettingName, SystemSettingDescription, DataType, DefaultValue, SystemSettingValue, SystemSettingCategoryID)
	VALUES
		((SELECT MAX(SystemSettingID)+1 FROM SystemSettingValue), 'WebPlusMarkbookCompleteTickColour', 'The colour of the Markbook Complete Checkbox Tick', 'System.String', '#FFFFFF', '#FFFFFF', 1)
END
IF NOT EXISTS (SELECT 1 FROM SystemSettingValue WHERE SystemSettingName = 'WebPlusMarkbookCompleteBgdColour')
BEGIN
	INSERT INTO	
		SystemSettingValue
			(SystemSettingID, SystemSettingName, SystemSettingDescription, DataType, DefaultValue, SystemSettingValue, SystemSettingCategoryID)
	VALUES
		((SELECT MAX(SystemSettingID)+1 FROM SystemSettingValue), 'WebPlusMarkbookCompleteBgdColour', 'The colour of the Markbook Complete Checkbox Background', 'System.String', '#a4ce55', '#a4ce55', 1)
END
GO

--added 25/7/2025 v1.40.1
IF NOT EXISTS (SELECT 1 FROM SystemSettingValue WHERE SystemSettingName = 'WebPlusMarkbookDisplay')
BEGIN
	INSERT INTO	
		SystemSettingValue
			(SystemSettingID, SystemSettingName, SystemSettingDescription, DataType, DefaultValue, SystemSettingValue, SystemSettingCategoryID)
	VALUES
		((SELECT MAX(SystemSettingID)+1 FROM SystemSettingValue), 'WebPlusMarkbookDisplay', 'Controls the Markbook functionality (when MB not Licensed) as follows: SHOW=Show the Markbook Popup/Tab/Reports  HIDE=Hide the Markbook Popup/Tab/Reports', 'System.String', 'HIDE', 'HIDE', 1)
END
GO
